#include "is_functions.h"

int main()
{

	point a, b, c, d;

	std::vector<bool> intersects;

	int t = -1;

	int n = 0;

	int seed = 0;

	std::cin >> n >> t;

	if(t == 0)
	{
		for(int i = 0; i < n; i++)
		{

			std::cin >> a.x >> a.y
						>> b.x >> b.y
						>> c.x >> c.y
						>> d.x >> d.y;
			intersects.push_back(fast_intersect(a, b, c, d));
		}
	}

	if(t == 1)
	{
		std::cin >> seed;
		RandomInput inp(seed);
		for(int i = 0; i < n; i++)
		{
			a.x = inp.get_double();
			a.y = inp.get_double();
			b.x = inp.get_double();
			b.y = inp.get_double();
			c.x = inp.get_double();
			c.y = inp.get_double();
			d.x = inp.get_double();
			d.y = inp.get_double();
			intersects.push_back(fast_intersect(a, b, c, d));
		}
	}

	std::cout << get_result(intersects);

	return 0;
}